import { SAVE_USER_ASYNC, SAVE_USER, SAVE_ROUTES } from './actionType'

export const saveUserAction = (payload: any) => ({ type: SAVE_USER, payload })

export const saveUserActionAsync = () => ({ type: SAVE_USER_ASYNC })

export const getRoutes = () => {
  return async (dispatch: any) => {
    fetch('http://localhost:8080/getRoutes', { method: 'GET' })
      .then((res) => res.json())
      .then((res) => dispatch({ type: SAVE_ROUTES, payload: res }))
  }
}
/* 

/* 
export const saveUserAction = ()=>{
  return async (dispatch:any)=>{
    const res:any = await getUserInfo() // 获取用户信息
    return dispatch()
  }
}

*/
